{% extends "base_project.html" %}
{% load humanize static hc_extras %}

{% block title %}
{% if is_new %}
Set Up Email Notifications - {{ site_name }}
{% else %}
Email Settings - {{ site_name }}
{% endif %}
{% endblock %}


{% block content %}
<div class="row">
<div class="col-sm-12">
    <h1>Email</h1>
    <p>Get an email message when check goes up or down.</p>

    {% if use_verification %}
    <p class="alert alert-info">
        <strong>Requires confirmation.</strong>
        After entering an email address, {{ site_name }} will send out a confirmation link.
        Only confirmed addresses receive notifications.
    </p>
    {% endif %}

    <h2>Integration Settings</h2>

    <form method="post" class="form-horizontal">
        {% csrf_token %}
        <div class="form-group {{ form.value.css_classes }}">
            <label for="id_email" class="col-sm-2 control-label">Email</label>
            <div class="col-sm-3">
                <input
                    id="id_email"
                    type="email"
                    class="form-control"
                    name="value"
                    placeholder="you@example.org"
                    required
                    value="{{ form.value.value|default:"" }}">

                {% if form.value.errors %}
                <div class="help-block">
                    {{ form.value.errors|join:"" }}
                </div>
                {% endif %}
            </div>
        </div>

        <div class="form-group {{ form.down.css_classes }}">
            <label class="col-sm-2 control-label">Notify When</label>
            <div class="col-sm-10">
                <label class="checkbox-container">
                    <input
                        type="checkbox"
                        name="down"
                        value="true"
                        {% if form.down.value %} checked {% endif %}>
                    <span class="checkmark"></span>
                    A check goes <strong>down</strong>
                </label>
                <label class="checkbox-container">
                    <input
                        type="checkbox"
                        name="up"
                        value="true"
                        {% if form.up.value %} checked {% endif %}>
                    <span class="checkmark"></span>
                    A check goes <strong>up</strong>
                    {% if form.down.errors %}
                    <div class="help-block">
                        {{ form.down.errors|join:"" }}
                    </div>
                    {% else %}
                    <br />
                    <span class="text-muted">
                    Ticketing system integrations: untick this and avoid creating new tickets
                    when checks come back up.
                    </span>
                    {% endif %}
                </label>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">Save Integration</button>
            </div>
        </div>
    </form>
</div>
</div>
{% endblock %}
